package com.linkallcloud.deapi;

import com.alibaba.fastjson2.annotation.JSONField;

import java.io.Serializable;
import java.util.Date;


public class Tokens implements Serializable {
    private static final long serialVersionUID = -1654247871904396259L;

    private String refreshToken;// 刷新秘钥
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date refreshTokenValidTime;// 刷新秘钥有效

    private String requestToken;// 请求秘钥
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private Date requestTokenValidTime;// 请求秘钥有效

    public Tokens() {
        super();
    }

    public Tokens(String refreshToken, Date refreshTokenValidTime, String requestToken, Date requestTokenValidTime) {
        super();
        this.refreshToken = refreshToken;
        this.refreshTokenValidTime = refreshTokenValidTime;
        this.requestToken = requestToken;
        this.requestTokenValidTime = requestTokenValidTime;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public Date getRefreshTokenValidTime() {
        return refreshTokenValidTime;
    }

    public void setRefreshTokenValidTime(Date refreshTokenValidTime) {
        this.refreshTokenValidTime = refreshTokenValidTime;
    }

    public Date getRequestTokenValidTime() {
        return requestTokenValidTime;
    }

    public void setRequestTokenValidTime(Date requestTokenValidTime) {
        this.requestTokenValidTime = requestTokenValidTime;
    }

    public String getRequestToken() {
        return requestToken;
    }

    public void setRequestToken(String requestToken) {
        this.requestToken = requestToken;
    }

    @JSONField(serialize = false)
    public boolean isRefreshTokenTimeout() {
        return getRefreshTokenValidTime().before(new Date());// 默认超时时间：48小时
    }

    @JSONField(serialize = false)
    public boolean isRequestTokenTimeout() {
        return this.getRequestTokenValidTime().before(new Date());// 默认超时时间：15分钟
    }

}
